package interprefer.pattern.demo;

import java.util.Scanner;

/**
 * Created by 逸足天涯
 * Date: 2019/10/21.
 * Time: 14:58
 */
public class InterprePatternEx {
    public Context clientContext = null;
    public IExpression exp = null;

    public InterprePatternEx(Context c) {

        this.clientContext = c;
    }

    public void interpret(String str){
        for (int i = 0; i < 2; i++) {
            System.out.println("\nEnter your choice (1 or 2):");
            Scanner in = new Scanner(System.in);
            String c = in.nextLine();

            if(c.equals("1")){
                exp = new IntToWords(str);
                exp.interpret(clientContext);
            }else{
                exp = new StringToBinaryExp(str);
                exp.interpret(clientContext);
            }
        }
    }

    public static void main(String[] args) {
        System.out.println("\n***Interprefer Pattern Demo***");
        System.out.println("Enter a number : ");
        Scanner in = new Scanner(System.in);

        String input = in.nextLine();
        Context context = new Context(input);
        InterprePatternEx client = new InterprePatternEx(context);
        client.interpret(input);
    }

}
